package amd.ui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;

public class GUISetting {

    public static JButton getButton(String text, String action, ActionListener listener) {
        JButton button = new JButton();
        button.setText(text);
        button.setActionCommand(action);
        button.addActionListener(listener);
        button.setCursor(new Cursor(Cursor.HAND_CURSOR));
        button.setFont(new Font("Dialog", Font.PLAIN, 12));
        return button;
    }

    public static JButton setButton(JButton button, Rectangle bound, String iconLocation) {
        button.setBounds(bound);
        button.setIcon(new ImageIcon(iconLocation));
        return button;
    }

    public static JButton setToolbarButton(JButton toolbarButton, String tooltip) {
        toolbarButton.setToolTipText(tooltip);
        return toolbarButton;
    }

    public static JLabel getLabel(String text) {
        JLabel label = new JLabel();
        label.setText(text);
        label.setFont(new Font("Dialog", Font.PLAIN, 12));
        return label;
    }

    public static JLabel setLabel(JLabel label, Rectangle bounds) {
        label.setBounds(bounds);
        return label;
    }

    public static JLabel setLabel(JLabel label, Rectangle bounds, String iconLocation) {
        label.setBounds(bounds);
        label.setIcon(new ImageIcon(iconLocation));
        return label;
    }

    /* public static JLabel setLabel( String action, MouseListener listener )
    {
    JLabel label = new JLabel();
    //label.setActionCommand( action );
    label.addMouseListener( listener );
    label.setCursor( new Cursor( Cursor.HAND_CURSOR ) );

    return label;
    }*/
    public static JTextField getTextField(int width, String text) {
        JTextField txtField = new JTextField(width);
        txtField.setText(text);
        txtField.setFont(new Font("Dialog", Font.PLAIN, 12));
        txtField.setSelectionColor(new Color(200, 150, 150));
        txtField.setSelectedTextColor(new Color(255, 255, 255));
        txtField.setCursor(new Cursor(Cursor.TEXT_CURSOR));

        return txtField;
    }

    public static JTextField getTextField(int width) {
        JTextField txtField = new JTextField(width);
        txtField.setFont(new Font("Dialog", Font.PLAIN, 12));
        txtField.setSelectionColor(new Color(200, 150, 150));
        txtField.setSelectedTextColor(new Color(255, 255, 255));
        txtField.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        return txtField;
    }

    public static JTextField setTextField(JTextField txtField, Rectangle bounds) {
        txtField.setBounds(bounds);
        return txtField;
    }

    public static JTextField getTextField() {
        JTextField txtField = new JTextField();
        txtField.setFont(new Font("Dialog", Font.PLAIN, 12));
        txtField.setSelectionColor(new Color(200, 150, 150));
        txtField.setSelectedTextColor(new Color(255, 255, 255));
        txtField.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        return txtField;
    }

    public static JTextField setTextField(JTextField txtField, Rectangle bounds, boolean enable) {
        txtField.setEnabled(enable);
        txtField.setBounds(bounds);
        return txtField;
    }

    public static JTextField setTextField(JTextField txtField, Rectangle bounds, String action, ActionListener listener) {
        txtField.setBounds(bounds);
        txtField.setActionCommand(action);
        txtField.addActionListener(listener);
        return txtField;
    }

    public static JTextArea getTextArea() {

        JTextArea textArea = new JTextArea();
        textArea.setFont(new Font("Dialog", Font.PLAIN, 12));
        textArea.setBackground(Color.white);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);

        return textArea;
    }

    public static JTextArea setTextArea(JTextArea textArea, Rectangle bounds) {
        textArea.setBounds(bounds);
        return textArea;
    }
}